define(function(require, exports, module) {

	var common = require('common');

	var init = function() {

        /* 控件事件绑定 */
		$("#btnMenuList, #btnReturn").click(function() {
			common.ajaxLoadPage($(this).attr("href"));
			return false;
		});
		$("#btnSave").click(function() {
			if ($("#menuInfoForm").validate().form()) {
				$("#menuInfoForm").submit();
			}
		});
        $("#btnIcon").click(function() {
            common.showModal("选择图图表", "sys/iconList.html", 660, function(subPbox) {
                seajs.use("../static/sys/iconList.js", function(icon) {
                    icon.init(subPbox);
                });
            }, null, function(returnVal) {
                $("#btnIcon").attr("disabled", false);
                $("#menuIcon").html(returnVal);
            });
            $(this).attr("disabled", true);
        });
        $("#menuType").change(function() {
            $("#btnIcon").attr("disabled", true);
            $("#menuLink").attr("disabled", true);
            if ($(this).val() == "1") {
                $("#btnIcon").attr("disabled", false);
            } else if ($(this).val() == "2") {
                $("#btnIcon").attr("disabled", false);
            } else if ($(this).val() == "3") {
                $("#menuLink").attr("disabled", false);
            }
        });

        /* 画面提交定义 */
		var rules = {
                menuName : {
                    required : true
                },
                menuSort : {
                    required : true
                }
            };
		common.handleSubmit($("#menuInfoForm"), rules);


        /* 控件初始化 */
        $("select").select2();
	}

	return {
		init : init
	}
});